package model.member.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import common.SearchDto;
import model.member.dto.EventDto;
import model.member.dto.FavorDto;
import model.member.dto.MemberDto;
import model.member.dto.ZipcodeDto;

public class MemberDaoImpl implements MemberDao{
	private SqlSession sqlSession;
	public void setSqlSession(SqlSession sqlSession) {
		this.sqlSession = sqlSession;
	}
	/////////////////////////////////
	@Override
	public MemberDto login(MemberDto dto) {
		return sqlSession.selectOne("member.login", dto);
	}
	@Override
	public int useridCheck(String userid) {		
		return sqlSession.selectOne("member.useridCheck", userid);
	}
	@Override
	public List<ZipcodeDto> zipcodeList(String dong) {
		return sqlSession.selectList("member.zipcodeSearch", dong);
	}
	@Override
	public int memberInsert(MemberDto dto) {		
		return sqlSession.insert("member.join", dto);
	}
	/////////////////
	@Override
	public List<MemberDto> memberList(SearchDto search) {
		if(search.getOp_level().equals("0")){
			return sqlSession.selectList("member.listAll", search);
		}
		return sqlSession.selectList("member.list", search);
	}
	@Override
	public int memberCount(SearchDto search) {
		if(search.getOp_level().equals("0")){
			return sqlSession.selectOne("member.countAll", search);
		}
		return sqlSession.selectOne("member.count", search);
	}
	@Override
	public void mbLevelUpdate(MemberDto dto) {
		sqlSession.update("member.mb_level_update", dto);
	}
	@Override
	public MemberDto memberDetail(String userid) {
		return sqlSession.selectOne("member.memberDetail", userid);
	}
	@Override
	public void favoridInsert(MemberDto dto) {
		sqlSession.insert("member.addFavorMember", dto);
	}
	@Override
	public void favoridDelete(FavorDto dto) {
		sqlSession.delete("member.delFavorMember", dto);
	}
	@Override
	public int favoridCheck(MemberDto dto) {
		return sqlSession.selectOne("member.favoridCheck", dto);
	}
	@Override
	public List<FavorDto> myMemberList(String userid) {
		return sqlSession.selectList("member.myFavorMemberList", userid);
	}
	@Override
	public List<FavorDto> myRecipeList(String userid) {
		return sqlSession.selectList("member.myFavorRecipeList", userid);
	}
	@Override
	public void favorRecipeDelete(FavorDto dto) {
		sqlSession.delete("member.delFavorRecipe", dto);
	}
	@Override
	public List<EventDto> myEvents(String userid) {
		return sqlSession.selectList("member.myEventList", userid);
	}
	@Override
	public void favorRecipeInsert(MemberDto dto) {
		sqlSession.insert("member.addFavorRecipe", dto);
	}
	@Override
	public int favorRecipeCheck(MemberDto dto) {
		return sqlSession.selectOne("member.favorRecipeCheck", dto);
	}

	
	
	
}
